home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TeX 1995 July
/
TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO
/
web
/
noweb
/
src
/
shell
/
noweb.nw
(
.txt
)
< prev
next >
Wrap
LaTeX Document
|
1995-02-24
|
2KB
|
64 lines
\section{Generating all outputs from a {\tt noweb} file}
The copyright applies both to the {\tt noweb} source and to the
generated shell script.
<<copyright notice>>=
# Copyright 1991 by Norman Ramsey. All rights reserved.
# See file COPYRIGHT for more information.
Here's the organization of the source:
<<noweb>>=
#!/bin/sh
<<copyright notice>>
LIB=|LIBDIR|
markup=$LIB/markup mntopt=-L status=0 tex=1 output=1
<<consume options, setting [[tex]], [[output]], [[mntopt]], and [[markup]]>>
if [ $# -eq 0 ]; then <<complain of no args and exit>>; fi
for source do
if [ -n "$output" ]; then
PATH="$PATH:$LIB" $markup -t $source | $LIB/mnt -t8 "$mntopt" -all || status=1
if [ -n "$tex" ]; then
<<write {\TeX} output>> || status=1
exit $status
{\tt noweb} could be modified to follow two Knuth-like and {\tt nuweb}-like conventions:
\begin{itemize}
\item
Treat multiple white space within chunk names as single blanks, and
ignore leading and trailing whitespace.
\item
Permit chunk names to be abbreviated by writing an initial subsequence
of the name followed by ``[[...]]''.
\end{itemize}
The modification is simple; just add these two programs to the
pipeline.
([[disambiguate]] is an Icon program found in the [[icon]] directory
of the [[noweb]] distribution.)
<<compress multiple blanks in uses and defns>>=
sed -e '/^@[ud][se][ef][ n]/s/[ ][ ]*/ /g' \
-e '/^@[ud][se][ef][ n]/s/ $//'
<<disambiguate uses and defns ending in three dots>>=
$LIB/disambiguate
When writing {\TeX} output, I call [[$markup]] a second time to expand tabs.
%% timings on nuweb
% markup 0.4u 0.1s
% noxref 3.9u 1.0s
% nawk 6.5u 0.2s
<<write {\TeX} output>>=
texname=`echo $source | sed '/\./s/\.[^.]*$//'`
texname="$texname.tex"
PATH="$PATH:$LIB" $markup $source | $LIB/finduses -noquote | $LIB/noidx -delay |
nawk '{print}
/^@defn [^ ]*$/ { print "@literal \\let\\nwnotused=\\nwoutput{}" }' |
$LIB/totex -delay | cpif $texname
<<consume options, setting [[tex]], [[output]], [[mntopt]], and [[markup]]>>=
while [ $# -gt 0 ]; do
case $1 in
-to|-ot) tex= output= ; shift ;;
-t) tex= ; shift ;;
-o) output= ; shift ;;
-L*) mntopt="$1" ; shift ;;
-markup) markup="$2" ; shift; shift ;;
-*) echo "Unrecognized option $1" 1>&2; exit 1 ;;
*) break ;;
esac
<<complain of no args and exit>>=
echo "Usage: $0 [-L[fmt] -t -o] file [...]" 1>&2; exit 1